﻿#region << 文件说明 >>
/*----------------------------------------------------------------
 * 命名空间：Vampirewal.Core.Models
 * 唯一标识：71b03d29-3d2e-4e75-8cc4-67aaa46522e5
 * 文件名：PageNumberModel
 * 
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2023/10/30 11:33:30
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/
#endregion << 文件说明 >>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Vampirewal.Core.Models;

/// <summary>
/// 页码模型
/// </summary>
public class PageNumberModel
{
    /// <summary>
    /// 总条数
    /// </summary>
    public int TotalCount { get; set; }

    /// <summary>
    /// 当前页数
    /// </summary>
    public int CurrentPageNo { get; set; }

    /// <summary>
    /// 页条目数
    /// </summary>
    public int PageCount { get; set; }

    /// <summary>
    /// 搜索内容
    /// </summary>
    public object SearchText { get; set; }
}

/// <summary>
/// 基础分页模型
/// </summary>
public class PageBaseModel<T> : PageNumberModel where T : TopModel
{
    /// <summary>
    /// 创建分页返回对象
    /// </summary>
    /// <param name="totalCount">总条数</param>
    /// <param name="currentPageNo">当前页码</param>
    /// <param name="pageCount">一页展示条数</param>
    /// <param name="items"></param>
    public PageBaseModel(int totalCount, int currentPageNo, int pageCount, IEnumerable<T> items)
    {
        ItemSource = new List<T>(items);
        TotalCount = totalCount;
        CurrentPageNo = currentPageNo;
        PageCount = pageCount;
        IsSuccess = true;
    }

    public PageBaseModel(string error)
    {
        ItemSource = new List<T>();
        Error = error;
    }


    /// <summary>
    /// 数据列表
    /// </summary>
    public List<T> ItemSource { get; }

    /// <summary>
    /// 是否成功
    /// </summary>
    public bool IsSuccess { get; }

    /// <summary>
    /// 错误信息
    /// </summary>
    public string Error { get; }
}

/// <summary>
/// 列表加载器容器
/// </summary>
public class ListContainer<T> where T : TopModel
{
    public ListContainer()
    {
        ItemSource = new List<T>();
    }

    /// <summary>
    /// 列表项
    /// </summary>
    public List<T> ItemSource { get; set; }

    /// <summary>
    /// 错误信息
    /// </summary>
    public string Error { get; set; }

    /// <summary>
    /// 是否成功
    /// </summary>
    public bool IsSuccess { get; set; }
}